package com.xjm_cloud_admin.util;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;

// 计算输出流字节数的包装类
public class CountingOutputStream extends FilterOutputStream {
    private long byteCount = 0;

    public CountingOutputStream(OutputStream out) {
        super(out);
    }

    @Override
    public void write(int b) throws IOException {
        super.write(b);
        byteCount++;
    }

    @Override
    public void write(byte[] b, int off, int len) throws IOException {
        super.write(b, off, len);
        byteCount += len;
    }

    public long getByteCount() {
        return byteCount;
    }
}